#ifndef LEVELEDITORMODE_H
#define LEVELEDITORMODE_H

#include "editormode.h"

class AbstractGameObject;
namespace LevelObjects { class AbstractLevelObject; }
namespace LevelModeWidgets { class LevelEditorView; }

namespace Modes {

class LevelEditorMode : public EditorMode
{
	Q_OBJECT
	friend class EditorModeManager;
public:
	LevelEditorMode(EditorModeManager& em);

	void enter();
	void exit();
	void updateGui();

	QPointer<LevelObjects::AbstractLevelObject> selectedLevel() const;
private:
	void onDocumentChanged(QPointer<Document> doc);
	QPointer<LevelObjects::AbstractLevelObject> m_selectedLevel;
	QPointer<AbstractGameObject> m_selectedActorPattern;
	// GUI
	void initDocks();
	void initActions();
	void initLevelToolbar();
	void createConnections();
	QPointer<LevelModeWidgets::LevelEditorView> m_levelEditorView;
	QPointer<QDockWidget> m_actorPatternsDock;
	QPointer<QDockWidget> m_levelEditorDock;

	QPointer<QMenu> m_levelMenu;
	QPointer<QAction> m_createLevelAct;
	QPointer<QAction> m_addActorAct;
	QPointer<QAction> m_deleteLevelObjectAct;

	QPointer<QToolBar> m_levelToolbar;
signals:
	void populateActorPatternsView();
signals:
	void levelCreated(QPointer<LevelObjects::AbstractLevelObject> level);
	void levelDeleted(QPointer<LevelObjects::AbstractLevelObject> level);
	// to notify gui
	void selectedLevelChanged(QPointer<LevelObjects::AbstractLevelObject> lo);
public slots:
	// notification from tree widget
	void onSelectedLevelChanged(QPointer<LevelObjects::AbstractLevelObject> lo);
	// notification from list widget
	void onSelectedActorPatternChanged(QPointer<AbstractGameObject> go);
	
	void onCreateLevel();
	void onDeleteLevel();
	void onAddActor();
	void onDeleteActor();
private:
	void onObjectSelectionChanged();
};

} // Modes

#endif // LEVELEDITORMODE_H
